package cn.rkylin.oms.warehouse.stock.dao;

import cn.rkylin.core.IDataBaseFactory;
import cn.rkylin.oms.warehouse.stock.domain.Stock;
import cn.rkylin.oms.warehouse.stock.domain.StockBalance;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 库存DAO实现类
 * @author liming
 * @date 2017/10/30
 */
@Repository(value = "stockDAO")
public class StockDAOImpl implements IStockDAO {
    @Autowired
    protected IDataBaseFactory dao;

    /**
     * 获取库存列表
     *
     * @param stock
     * @return
     * @throws Exception
     */
    @Override
    public List<Stock> findByWhere(Stock stock) throws Exception {
        List<Stock> stockList = dao.findAllList("selectByPrimaryKeyStock",stock);
        return stockList;
    }

    /**
     * 插入库存结余
     *
     * @param stockBalance
     * @return
     * @throws Exception
     */
    @Override
    public int insertStockBalance(StockBalance stockBalance) throws Exception {
        return dao.insert("insertSelectiveStockBalance",stockBalance);
    }

    /**
     * 查询库存结余.
     * @see cn.rkylin.oms.warehouse.stock.dao.IStockDAO#findStockBalanceByWhere(cn.rkylin.oms.warehouse.stock.domain.Stock)
     */
    @Override
    public List<StockBalance> findStockBalanceByWhere(String storId) throws Exception {
        List<StockBalance> stockList = dao.findAllList("selectStockBalanceByPrimaryKeyStock",storId);
        return stockList;
    }
}
